// Package handlers 处理器包
package handlers

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

// APIEndpoint API端点信息
type APIEndpoint struct {
	Path        string `json:"path"`         // 路径
	Method      string `json:"method"`       // HTTP方法
	Description string `json:"description"`  // 描述
	Group       string `json:"group"`        // 分组
}

// APIHandler API信息处理器
type APIHandler struct{}

// NewAPIHandler 创建新的API信息处理器
func NewAPIHandler() *APIHandler {
	return &APIHandler{}
}

// ListAPIs 列出所有API端点
func (h *APIHandler) ListAPIs(c *gin.Context) {
	endpoints := []APIEndpoint{
		{
			Path:        "/api/v1/users",
			Method:      "POST",
			Description: "创建新用户",
			Group:       "users",
		},
		{
			Path:        "/api/v1/users",
			Method:      "GET",
			Description: "获取所有用户列表",
			Group:       "users",
		},
		{
			Path:        "/api/v1/users/:id",
			Method:      "GET",
			Description: "获取指定用户信息",
			Group:       "users",
		},
		{
			Path:        "/api/v1/users/:id",
			Method:      "PUT",
			Description: "更新指定用户信息",
			Group:       "users",
		},
		{
			Path:        "/api/v1/users/:id",
			Method:      "DELETE",
			Description: "删除指定用户",
			Group:       "users",
		},
		{
			Path:        "/api/v1",
			Method:      "GET",
			Description: "获取API端点列表",
			Group:       "api",
		},
	}

	c.JSON(http.StatusOK, gin.H{
		"total": len(endpoints),
		"apis":  endpoints,
	})
}
